Adjust custom rankings per category.
category
: a list with all category names for this product—ranked and not ranked. This is used for faceting the search results. See Creating a category data attribute for more information, and how to implement hierarchical categories.ranked_category
: the name of the category for which the product ranks. To show a product also for searches without category filters, one record per product must have ranked_category: none
.category_rank
: the rank of the product in the category. Each duplicate of the product’s record has one corresponding pair of ranked_category
and category_rank
attributes, which enables the per-category custom ranking.parent_objectID
: a unique identifier for events. When tracking click and conversion events with the Insights API, you use this identifier to link all events from the duplicate records to the same product.objectID
attribute as the unique identifier.
parent_objectID
has the same value as the objectID
of the first record. For tracking events, use the parent_objectID
attribute as the unique identifier.
parent_objectID
. It has the same value as the objectID
attribute of the first record.
category_rank
attribute to the top of the custom ranking criteria and sort the results by ascending values so that low values rank high. In the Algolia dashboard, choose your index and select Ranking and Sorting.
ranked_category
to the attributes for faceting. Since you want to use this attribute just for filtering the search results, use the filterOnly
modifier to discard the facet values and counts. This reduces the size of the index and speeds up the search. In the Dashboard, go to Facets and add the ranked_category
attribute.
sku
attribute as Attribute for Distinct.
distinct
is computationally intensive and can slow down the search.ranked_category
attribute. Depending on whether users search with or without categories, you need to filter the results dynamically:
ranked_category: none
attribute.
category: Shoes AND ranked_category: Shoes
category: Shoes AND ranked_category: none
distinct
for this index, results only show the record with ranked_category: Shoes
.
If users search in a different category, for example, the category Accessories, the results show the record matching category: Accessories and ranked_category: none
.
These rules decide the ranking between records with and without ranked categories:
ranked_category
and category_rank
attributes. Since they have the same textual relevance, Algolia ranks them by their custom ranking attributes.
category_rank
. As the record with ranked_category:none
doesn’t have a category_rank
attribute, it ranks lower than a record with a value for this attribute.
distinct(true)
, the search returns the first record from a list of identical records. Because you set attributeForDistinct
to sku
, all products with the same sku
attribute are identical.
facetingAfterDistinct
to true
. You have to apply this setting at query time.